package net.maku.framework.common.utils;

import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * 获取真实地址
 *
 * @author 阿沐 babamu@126.com
 * <a href="https://maku.net">MAKU</a>
 */
@Slf4j
public class MybatisUtils {
    public static ThreadLocal<Boolean> openFill = new ThreadLocal<Boolean>();
    public static ThreadLocal<Map<String,Object>> variable = new ThreadLocal<Map<String,Object>>();

    public static Boolean getFill() {
        return openFill.get() == null ? true : openFill.get();
    }

    public static void openFill() {
        MybatisUtils.openFill.remove();
    }

    public static void closeFill() {
        MybatisUtils.openFill.set(false);
    }

    public static void putVariable(String key,Object value){
        if(variable.get()==null){
            variable.set(new HashMap());
        }
        variable.get().put(key,value);
    }

    public static void clearVariable(){
        variable.get().clear();
        variable.set(null);
    }
}
